package equipmentManager.main;

import equipmentManager.dao.EquipmentDao;
import equipmentManager.utils.Utils;

public class Main {

    public static void main(String[] args) {
        //设备库
        EquipmentDao equipmentDao = new EquipmentDao();
        while (true){
            ui();
            //"\S{1,10}"
            String menu = Utils.getString("[1-9]");
            switch (menu){
                case "1"://添加设备
                    equipmentDao.add();
                    break;
                case "2"://查询设备
                    equipmentDao.query();
                    break;
                case "3"://删除设备
                    equipmentDao.delete();
                    break;
                case "4"://借出
                    equipmentDao.lend();
                    break;
                case "5"://归还
                    equipmentDao.returnBack();
                    break;
                case "9"://退出
                    System.out.print("确定要退出吗？(y/n)：");
                    if(Utils.getYN().equals("Y")){
                        System.out.println("退出成功！");
                        System.exit(0);
                    }
                    System.out.println("取消退出！");
                    break;
            }

        }
    }

    /**
     * 界面
     */
    public static void ui() {
        System.out.println("==欢迎使用·设备管理系统==");
        System.out.println("====================");
        System.out.println("1. 添加设备");
        System.out.println("2. 查询设备");
        System.out.println("3. 删除设备");
        System.out.println("4. 借出设备");
        System.out.println("5. 归还设备");
        System.out.println("9. 退出");
        System.out.print("请选择菜单：");
    }
}
